//
//  DATImage.m
//  MapEdit
//
//  Created by Steven Canfield on 28/06/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "DATImage.h"

#define NUM_IMAGE 999

@implementation DATImage
- (id)initWithData:(NSData *)data {
	self = [super init];
	if( self ) {
		images = malloc( sizeof( dat_image_t ) * NUM_IMAGE );
		
		int imageIndex;
		int dataIndex = 0;
		for( imageIndex = 0; imageIndex < NUM_IMAGE; imageIndex++ ) {
			/* Read Unit Info */
			u_int32_t buff32;
			[data getBytes:&buff32 range:NSMakeRange( dataIndex, sizeof( u_int32_t ))];
			buff32 = NSSwapLittleIntToHost( buff32 );
			dataIndex += sizeof( u_int32_t );
			images[ imageIndex ].image_tbl_index = buff32;
		}
	}
	return self;
}


- (dat_image_t *)imageAtIndex:(int)index {
//	NSLog(@"%@ => %i", NSStringFromSelector(_cmd), index );
	return &( images[ index ] );
}

@end
